package org.codefinger.dao.impl;

import org.codefinger.dao.impl.sql.ast.TextExpression;
import org.codefinger.dao.util.ArrayIterator;
import org.codefinger.dao.util.Lang;

public class AsteriskColumnCache implements ColumnCache {

	private String	name;

	public AsteriskColumnCache(String name) {
		super();
		this.name = name;
	}

	@Override
	public void resolveColumn(QueryBuilder builder) {
		String tableAlias = name;
		ArrayIterator<String> iterator = builder.getAllColumns(tableAlias);
		String name;
		while (iterator.hasNext()) {
			name = iterator.next();
			builder.addColumnItem(new TextExpression(//
					Lang.joinStr(tableAlias.length() + 1 + name.length(), tableAlias, ".", name)), name, name);
		}
	}
}
